home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / FloatEnt.tcl.z / FloatEnt.tcl
Encoding:
Text File  |  1999-01-26  |  2.9 KB  |  127 lines

  1. # FloatEnt.tcl --
  2. #
  3. #    An entry widget that can be attached on top of any widget to
  4. #    provide dynamic editing. It is used to provide dynamic editing
  5. #    for the tixGrid widget, among other things.
  6. #
  7. # Copyright (c) 1996, Expert Interface Technologies
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12.  
  13. tixWidgetClass tixFloatEntry {
  14.     -classname TixFloatEntry
  15.     -superclass tixPrimitive
  16.     -method {
  17.     invoke post unpost
  18.     }
  19.     -flag {
  20.     -command -value
  21.     }
  22.     -configspec {
  23.     {-value value Value ""}
  24.     {-command command Command ""}
  25.     }
  26.     -default {
  27.     {.entry.highlightThickness    0}
  28.     }
  29. }
  30.  
  31. #----------------------------------------------------------------------
  32. #
  33. #    Initialization bindings
  34. #
  35. #----------------------------------------------------------------------
  36.  
  37. proc tixFloatEntry:InitWidgetRec {w} {
  38.     upvar #0 $w data
  39.  
  40.     tixChainMethod $w InitWidgetRec
  41. }
  42.  
  43. proc tixFloatEntry:ConstructWidget {w} {
  44.     upvar #0 $w data
  45.  
  46.     tixChainMethod $w ConstructWidget
  47.     set data(w:entry) [entry $w.entry]
  48.     pack $data(w:entry) -expand yes -fill both
  49. }
  50.  
  51. proc tixFloatEntry:SetBindings {w} {
  52.     upvar #0 $w data
  53.  
  54.     tixChainMethod $w SetBindings
  55.     tixBind $data(w:entry) <Return> "tixFloatEntry:invoke $w"
  56. }
  57.  
  58. #----------------------------------------------------------------------
  59. #
  60. #    Class bindings
  61. #
  62. #----------------------------------------------------------------------
  63.  
  64. proc tixFloatEntryBind {} {
  65.     tixBind TixFloatEntry <FocusIn>  {
  66.       if {![tixStrEq [focus -displayof [set %W(w:entry)]] [set %W(w:entry)]]} {
  67.       focus [%W subwidget entry]
  68.       [set %W(w:entry)] selection from 0
  69.       [set %W(w:entry)] selection to end
  70.       [set %W(w:entry)] icursor end
  71.       }
  72.     }
  73. }
  74.  
  75. #----------------------------------------------------------------------
  76. #
  77. #    Public methods
  78. #
  79. #----------------------------------------------------------------------
  80. proc tixFloatEntry:post {w x y {width ""} {height ""}} {
  81.     upvar #0 $w data
  82.  
  83.     if {$width == ""} {
  84.     set width [winfo reqwidth $data(w:entry)]
  85.     }
  86.     if {$height == ""} {
  87.     set height [winfo reqheight $data(w:entry)]
  88.     }
  89.  
  90.     place $w -x $x -y $y -width $width -height $height -bordermode ignore
  91.     raise $w
  92.     focus $data(w:entry)
  93. }
  94.  
  95. proc tixFloatEntry:unpost {w} {
  96.     upvar #0 $w data
  97.  
  98.     place forget $w
  99. }
  100.  
  101. proc tixFloatEntry:config-value {w val} {
  102.     upvar #0 $w data
  103.  
  104.     $data(w:entry) delete 0 end
  105.     $data(w:entry) insert 0 $val
  106.  
  107.     $data(w:entry) selection from 0
  108.     $data(w:entry) selection to end
  109.     $data(w:entry) icursor end
  110. }
  111. #----------------------------------------------------------------------
  112. #
  113. #    Private methods
  114. #
  115. #----------------------------------------------------------------------
  116.  
  117. proc tixFloatEntry:invoke {w} {
  118.     upvar #0 $w data
  119.  
  120.     if ![tixStrEq $data(-command) ""] {
  121.     set bind(specs) {%V}
  122.     set bind(%V)    [$data(w:entry) get]
  123.  
  124.     tixEvalCmdBinding $w $data(-command) bind $bind(%V)
  125.     }
  126. }
  127.